<template>
  <div class="relative-box">
    <div class="tip-box">
      <el-card :body-style="{padding:'5px 10px 5px 10px'}" shadow="hover">
        <span>{{ dateStr }}</span>
        <el-divider direction="vertical"></el-divider>
        <span>{{ weekStr }}</span>
        <!-- <el-divider direction="vertical"></el-divider>
        <span>Ver: {{ version }}</span> -->
      </el-card>
    </div>
    <div class="welcome-container">
      <el-row>
        <el-col :span="24">
          <div class="header">
            <h1 class="title">欢迎使用{{ appName }}</h1>
            <p class="subtitle">智慧管理，高效工作</p>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <i class="el-icon el-icon-s-promotion"></i><span>&nbsp;功能快捷入口</span>
            </div>
            <div class="shortcut-container">
              <el-row :gutter="20">
                <el-col :span="6" v-for="(item, index) in shortcuts" :key="index">
                  <el-card class="shortcut-card" shadow="hover" @click.native="goToModule(item.route)">
                    <div class="shortcut-icon">
                      <i :class="item.icon" class="el-icon"></i>
                    </div>
                    <div class="shortcut-name">{{ item.name }}</div>
                  </el-card>
                </el-col>
              </el-row>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>

export default {
  name: "Index",
  data() {
    return {
      appName: process.env.VUE_APP_TITLE
      , shortcuts: [
        {
          name: "生产管理",
          icon: "el-icon-suitcase",
          route: "/materiel/materielOneIndex",
        },
        {
          name: "资产管理",
          icon: "el-icon-money",
          route: "/asset/assetIndex",
        },
        {
          name: "文件共享",
          icon: "el-icon-s-help",
          route: "/fileshare/index",
        },
        {
          name: "系统设置",
          icon: "el-icon-setting",
          route: "/system/user",
        },
      ],
      dateStr:"",
      weekStr:""
    };
  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    }
    ,goToModule(route) {
      this.$router.push(route);
    },
    updateDateTime(){
      var date = new Date(); //获取当前日期
      var year = date.getFullYear(); //获取当前年份
      var month = date.getMonth() + 1; //获取当前月份（0-11）
      var day = date.getDate(); //获取当前日
      var hours = date.getHours(); //获取当前小时数（0-23）
      var minutes = date.getMinutes(); //获取当前分钟数（0-59）
      var seconds = date.getSeconds(); //获取当前秒数（0-59）
      if(hours<10){
        hours = "0"+hours; 
      }
      if(minutes<10){
        minutes = "0"+minutes; 
      }
      if(seconds<10){
        seconds = "0"+seconds; 
      }
      this.dateStr = year + "年" + month + "月" + day+"日 "+hours+":"+minutes+":"+seconds;
    }
  }
  ,mounted(){
    var date = new Date(); //获取当前日期
    var year = date.getFullYear(); //获取当前年份
    var month = date.getMonth() + 1; //获取当前月份（0-11） 
    var day = date.getDate(); //获取当前日
    var week = date.getDay(); //获取当前星期几（0-6）
    var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
    this.dateStr = year + "年" + month + "月" + day+"日";
    this.weekStr = weeks[week];
    setInterval(() => {
      this.updateDateTime();
    }, 1000);
  }
};
</script>

<style scoped lang="scss">
.relative-box {
  position: relative;
}
.tip-box {
  position: absolute;
  top: 10px;
  right: 10px; 
}
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 76vh;
  background: linear-gradient(180deg, rgba(31, 125, 232, 0.629), rgba(255, 255, 255, 0.529));
  background-size: cover;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.title {
  font-size: 36px;
  color: #39393a;
  font-weight: bold;
}

.subtitle {
  font-size: 18px;
  color: #575252;
  margin-top: 10px;
}

.box-card {
  width: 96%;
  margin: 0 auto;
}

.shortcut-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.shortcut-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
}

.shortcut-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.shortcut-icon {
  font-size: 36px;
  color: #409eff;
  margin-bottom: 10px;
}

.shortcut-name {
  font-size: 16px;
  color: #333;
}
</style>

